package Thread;

public class ThreadDemo03 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 5; i++) {
                System.out.println("我是一个线程，正在执行！");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程结束了");
        });

        t.start();

        t.join();
        System.out.println("main线程被执行了");
    }
}
